<?php


namespace core\event;

use core\entity\GroupUser;
use core\entity\Message;
use core\entity\User;
use core\entity\UserFactory;

class EventMessage extends Event {

    protected $message_type;

    protected $sub_type;

    protected $message;

    /**
     * @var User|GroupUser
     */
    protected $sender;

    public function __construct(array $input) {
        parent::__construct($input);
        $this->message_type = $input['message_type'];
        $this->sub_type = $input['sub_type'];
        $this->sender = UserFactory::build($this->message_type, $input['sender']);
        $this->message = new Message($input);
    }

    public function getMessage(): Message {
        return $this->message;
    }

    public function getSender() {
        return $this->sender;
    }

}
